<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加页面</title>
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/animate.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/style.css">
    <link rel="stylesheet" href="${request.contextPath}/hadmin/css/common.css">
    <link rel="stylesheet" href="${request.contextPath}/plugins/bootstrap-table/bootstrap-table.min.css">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="diseaseinfoAddForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">疾病名称：</label>
                            <div class="col-sm-9">
                                <input type="text" id="name" name="name" class="form-control" placeholder="请输入疾病名称"
                                       required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">科室名称：</label>
                            <div class="col-sm-9">
                                <select id="departmentId" name="departmentId" class="form-control select2" style="width: 100%;" required>
                                    <option value="">请选择所属科室</option>
                                    <#list departmentList as department>
                                        <option value="${(department.id)!}">${(department.name)!}</option>
                                    </#list>
                                </select>
                                <input type="hidden" id="departmentName" name="departmentName" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">身体部位：</label>
                            <div class="col-sm-9">
                                <select id="positionId" name="positionId" class="form-control select2" style="width: 100%;" required>
                                    <option value="">请选择身体部位</option>
                                    <#list bodyPartList as bodyPart>
                                        <option value="${(bodyPart.id)!}">${(bodyPart.name)!}</option>
                                    </#list>
                                </select>
                                <input type="hidden" id="positionName" name="positionName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">发病等级：</label>
                            <div class="col-sm-9">
                                <select id="morbidityId" name="morbidityId" class="form-control select2" style="width: 100%;" required>
                                    <option value="">请选择发病等级</option>
                                    <#list morbidityList as morbidity>
                                        <option value="${(morbidity.id)!}">${(morbidity.name)!}</option>
                                    </#list>
                                </select>
                                <input type="hidden" id="morbidityName" name="morbidityName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">疾病介绍：</label>
                            <div class="col-sm-9">
                                <textarea id="introduction" name="introduction" class="form-control"
                                          placeholder="请输入疾病介绍" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">临床表现：</label>
                            <div class="col-sm-9">
                                <textarea id="symptomDescription" name="symptomDescription" class="form-control"
                                          placeholder="请输入临床表现" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">检查：</label>
                            <div class="col-sm-9">
                                <textarea id="checkDescription" name="checkDescription" class="form-control"
                                          placeholder="请输入检查" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">治疗：</label>
                            <div class="col-sm-9">
                                <textarea id="treatment" name="treatment" class="form-control"
                                          placeholder="请输入治疗" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预防：</label>
                            <div class="col-sm-9">
                                <textarea id="prevention" name="prevention" class="form-control"
                                          placeholder="请输入预防" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">并发症：</label>
                            <div class="col-sm-9">
                                <textarea id="concurrent" name="concurrent" class="form-control"
                                          placeholder="请输入并发症" required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">诊断：</label>
                            <div class="col-sm-9">
                                <textarea id="diagnosis" name="diagnosis" class="form-control"
                                          placeholder="请输入诊断" required></textarea>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 通用js引入 -->
<script src="${request.contextPath}/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="${request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/plugins/select2/select2.full.min.js"></script>
<script src="${request.contextPath}/plugins/layer/layer.min.js"></script>
<script src="${request.contextPath}/plugins/laydate/laydate.js"></script>
<script src="${request.contextPath}/plugins/jquery-confirm/jquery-confirm.min.js"></script>
<script src="${request.contextPath}/plugins/validate/jquery.validate.min.js"></script>
<script src="${request.contextPath}/plugins/validate/messages_zh.min.js"></script>
<script src="${request.contextPath}/plugins/tinymce/tinymce.min.js"></script>
<script src="${request.contextPath}/plugins/blockUI/jquery.blockUI.js"></script>
<script src="${request.contextPath}/hadmin/js/content.js"></script>
<script src="${request.contextPath}/hadmin/js/common.js?v=0.9"></script>
<script>
    // select2 初始化
    $('.select2').select2({
        language: 'zh-CN'
    });
    $(".select2").change(function(){
        $(this).valid();
    });
    tinymce.init({
        selector: '#introduction',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#symptomDescription',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#checkDescription',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#treatment',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#prevention',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#concurrent',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });
    tinymce.init({
        selector: '#diagnosis',
        language: 'zh_CN',
        height: 300, //编辑器高度
        min_height: 300,
    });

    // 选择科室
    $("#departmentId").on('change',function(){
        if(!$("#departmentId").val()) {
            $("#departmentName").val("");
        } else {
            var text = $("#departmentId").select2('data')[0].text.trim();
            $("#departmentName").val(text);
        }
    })

    // 选择身体部位
    $("#positionId").on('change',function(){
        if(!$("#positionId").val()) {
            $("#positionName").val("");
        } else {
            var text = $("#positionId").select2('data')[0].text.trim();
            $("#positionName").val(text);
        }
    })

    // 选择发病等级
    $("#morbidityId").on('change',function(){
        if(!$("#morbidityId").val()) {
            $("#morbidityName").val("");
        } else {
            var text = $("#morbidityId").select2('data')[0].text.trim();
            $("#morbidityName").val(text);
        }
    })

    // 提交保存
    function submitHandler() {
        $("#introduction").val(tinyMCE.editors[0].getContent());
        $("#symptomDescription").val(tinyMCE.editors[1].getContent());
        $("#checkDescription").val(tinyMCE.editors[2].getContent());
        $("#treatment").val(tinyMCE.editors[3].getContent());
        $("#prevention").val(tinyMCE.editors[4].getContent());
        $("#concurrent").val(tinyMCE.editors[5].getContent());
        $("#diagnosis").val(tinyMCE.editors[6].getContent());
        if ($("#diseaseinfoAddForm").validate().form()) {
            saveInfo('${request.contextPath}/knowledge/diseaseinfo/doAdd', $('#diseaseinfoAddForm').serialize());
        } else {
            $("html,body").animate({scrollTop:0},1000);
            layer.msg("输入数据错误");
        }
    }
</script>
</body>
</html>
